From 8951ba8f4572db49a6b72614e95b3d5ea84646fb Mon Sep 17 00:00:00 2001
From: MonsieurPaulLeBoulanger
Date: Mon, 10 Jun 2013 16:23:48 +0200
Subject: [PATCH] improved starred/unstarred function, code refactoring using a
mode session var ('default', 'starred', 'history')
---
data/.htaccess | 1 -
index.php | 61 +++++++-------------------------------
templates/add.php | 2 +-
templates/app_header.php | 1 +
templates/history.php | 8 ++---
templates/read_item.php | 4 +--
templates/starred.php | 6 ++--
templates/starred_item.php | 10 +------
templates/unread_items.php | 4 +--
9 files changed, 24 insertions(+), 73 deletions(-)
delete mode 100644 data/.htaccess
diff --git a/data/.htaccess b/data/.htaccess
deleted file mode 100644
index 14249c5..0000000
--- a/data/.htaccess
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
\ No newline at end of file
diff --git a/index.php b/index.php
index 96522ba..8d3c352 100644
--- a/index.php
+++ b/index.php
@@ -104,7 +104,6 @@ Router\get_action('show', function() {
Router\get_action('show_starred_item', function() {
-
$id = Model\decode_item_id(Request\param('id'));
Response\html(Template\layout('starred_item', array(
@@ -148,7 +147,7 @@ Router\get_action('mark-item-read', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_read($id);
- Response\Redirect('?action=default');
+ Response\Redirect('?action='.$_SESSION['MODE']);
});
@@ -156,15 +155,7 @@ Router\get_action('mark-item-unread', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unread($id);
- Response\Redirect('?action=history');
-});
-
-
-Router\get_action('mark-read-item-unread', function() {
-
- $id = Model\decode_item_id(Request\param('id'));
- Model\set_item_unread($id);
- Response\Redirect('?action=history');
+ Response\Redirect('?action='.$_SESSION['MODE']);
});
@@ -172,15 +163,7 @@ Router\get_action('mark-item-removed', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_removed($id);
- Response\Redirect('?action=history');
-});
-
-
-Router\get_action('mark-starred-item-removed', function() {
-
- $id = Model\decode_item_id(Request\param('id'));
- Model\set_item_removed($id);
- Response\Redirect('?action=starred');
+ Response\Redirect('?action='.$_SESSION['MODE']);
});
@@ -199,43 +182,20 @@ Router\post_action('mark-item-unread', function() {
Response\json(array('Ok'));
});
-Router\get_action('mark-read-item-starred', function() {
+
+Router\get_action('mark-item-starred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_starred($id);
- Response\Redirect('?action=history');
+ Response\Redirect('?action='.$_SESSION['MODE']);
});
-Router\get_action('mark-read-item-unstarred', function() {
+Router\get_action('mark-item-unstarred', function() {
$id = Model\decode_item_id(Request\param('id'));
Model\set_item_unstarred($id);
- Response\Redirect('?action=history');
-});
-
-
-Router\get_action('mark-starred-item-unstarred', function() {
-
- $id = Model\decode_item_id(Request\param('id'));
- Model\set_item_unstarred($id);
- Response\Redirect('?action=starred');
-});
-
-
-Router\get_action('mark-unread-item-starred', function() {
-
- $id = Model\decode_item_id(Request\param('id'));
- Model\set_item_starred($id);
- Response\Redirect('?action=default');
-});
-
-
-Router\get_action('mark-unread-item-unstarred', function() {
-
- $id = Model\decode_item_id(Request\param('id'));
- Model\set_item_unstarred($id);
- Response\Redirect('?action=default');
+ Response\Redirect('?action='.$_SESSION['MODE']);
});
@@ -251,7 +211,7 @@ Router\post_action('change-item-status', function() {
Router\get_action('history', function() {
-
+ $_SESSION['MODE']='history';
Response\html(Template\layout('history', array(
'items' => Model\get_read_items(),
'menu' => 'history'
@@ -260,7 +220,7 @@ Router\get_action('history', function() {
Router\get_action('starred', function() {
-
+ $_SESSION['MODE']='starred';
Response\html(Template\layout('starred', array(
'items' => Model\get_starred_items(),
'menu' => 'starred'
@@ -481,6 +441,7 @@ Router\post_action('config', function() {
Router\notfound(function() {
+ $_SESSION['MODE']='default';
Model\autoflush();
diff --git a/templates/add.php b/templates/add.php
index abd1e4f..7be463c 100644
--- a/templates/add.php
+++ b/templates/add.php
@@ -13,4 +13,4 @@
-
\ No newline at end of file
+
diff --git a/templates/app_header.php b/templates/app_header.php
index 52a95e7..da9a4bc 100644
--- a/templates/app_header.php
+++ b/templates/app_header.php
@@ -1,4 +1,5 @@
+
diff --git a/templates/history.php b/templates/history.php
index 61da813..154dd79 100644
--- a/templates/history.php
+++ b/templates/history.php
@@ -29,15 +29,13 @@
- = t('mark as unstarred') ?> |
+ = t('mark as unstarred') ?> |
- = t('mark as starred') ?> |
+ = t('mark as starred') ?> |
-
-
- = t('mark as unread') ?> |
+ = t('mark as unread') ?> |
= t('remove') ?> |
|
= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
- = t('mark as unstarred') ?>
+ = t('mark as unstarred') ?>
- = t('mark as starred') ?>
+ = t('mark as starred') ?>
diff --git a/templates/starred.php b/templates/starred.php
index 0f7f488..188a36b 100644
--- a/templates/starred.php
+++ b/templates/starred.php
@@ -14,7 +14,7 @@